package com.student.db;


import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity(tableName = "db_account")
public class AccountEntity implements Parcelable {

    @NonNull
    @PrimaryKey
    private Long id;

    private String userName;
    private String passWord;

    private String name;
    //1代表男，0代表女
    private int sex;
    private String phoneNum;
    //0代表学生，1代表管理员
    private int type;
    //头像
    private String portraits;
    ///宿舍号
    private String roomNo;
    //楼栋
    private String floorNo;

    public String getRoomNo() {
        return roomNo;
    }

    public void setRoomNo(String roomNo) {
        this.roomNo = roomNo;
    }

    public int getType() {
        return type;
    }

    public String getPortraits() {
        return portraits;
    }

    public void setPortraits(String portraits) {
        this.portraits = portraits;
    }

    public void setType(int type) {
        this.type = type;
    }

    @NonNull
    public Long getId() {
        return id;
    }

    public void setId(@NonNull Long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }


    public String getName() {
        return name;
    }

    public void setName(String nickName) {
        this.name = nickName;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getFloorNo() {
        return floorNo;
    }

    public void setFloorNo(String floorNo) {
        this.floorNo = floorNo;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.userName);
        dest.writeString(this.passWord);
        dest.writeString(this.name);
        dest.writeInt(this.sex);
        dest.writeString(this.phoneNum);
        dest.writeInt(this.type);
        dest.writeString(this.portraits);
        dest.writeString(this.roomNo);
        dest.writeString(this.floorNo);
    }

    public void readFromParcel(Parcel source) {
        this.id = (Long) source.readValue(Long.class.getClassLoader());
        this.userName = source.readString();
        this.passWord = source.readString();
        this.name = source.readString();
        this.sex = source.readInt();
        this.phoneNum = source.readString();
        this.type = source.readInt();
        this.portraits = source.readString();
        this.roomNo = source.readString();
        this.floorNo = source.readString();
    }

    public AccountEntity() {
    }

    protected AccountEntity(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.userName = in.readString();
        this.passWord = in.readString();
        this.name = in.readString();
        this.sex = in.readInt();
        this.phoneNum = in.readString();
        this.type = in.readInt();
        this.portraits = in.readString();
        this.roomNo = in.readString();
        this.floorNo = in.readString();
    }

    public static final Parcelable.Creator<AccountEntity> CREATOR = new Parcelable.Creator<AccountEntity>() {
        @Override
        public AccountEntity createFromParcel(Parcel source) {
            return new AccountEntity(source);
        }

        @Override
        public AccountEntity[] newArray(int size) {
            return new AccountEntity[size];
        }
    };
}
